import Vue from 'vue'
import TopLoading from './index.vue'

var Loading = Vue.extend(TopLoading)

const loadingBox = new Loading({
  el: document.createElement('div')
})

const showLoading = {
  show() {
    loadingBox.show = true
    document.body.appendChild(loadingBox.$el)
  },
  beforeEnter() {
    this.show()
    loadingBox.loadingBefore = true
  },
  afterEnter() {
    loadingBox.loaded()
  }
}

export default showLoading
